package com.and;

import com.github.tobato.fastdfs.FdfsClientConfig;
import com.github.tobato.fastdfs.service.TrackerClient;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.annotation.PostConstruct;


@SpringBootApplication
@Import(FdfsClientConfig.class) // 关键！强制加载FastDFS配置
@EnableTransactionManagement
@EnableAsync
@EnableScheduling
public class VideoApp {

    public static void main(String[] args){
        ApplicationContext app = SpringApplication.run(VideoApp.class, args);
    }

    @Autowired
    private ApplicationContext context; // Spring 自动注入

    @PostConstruct
    public void checkFastDfs() {
        try {
            TrackerClient trackerClient = context.getBean(TrackerClient.class);
            System.out.println("FastDFS TrackerClient 已加载: " + trackerClient);
        } catch (NoSuchBeanDefinitionException e) {
            System.err.println("FastDFS 配置未生效！请检查 @Import(FdfsClientConfig.class)");
        }
    }
}
